package com.fau.cm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 客户健康档案表
 * @author kangyj
 * @datetime 2014年12月7日,上午11:18:41
 */
@Entity
@Table(name = "medical_call_customer_health")
public class MedicalCallCustomerHealth implements Serializable, JSONAware {

	private static final long serialVersionUID = -2181669440819397513L;
	
	private String id;
	private String customerId;				// 客户id
	private String healthArchiveId;			// 健康档案id
	private String description;				// 描述
	private String attendantId;				// 话务员id
	private String attendantName;			// 话务员姓名
	private Date createTime = new Date();	// 创建时间
	
	private MedicalCallHealthSymptom healthSymptom;		// 标准健康档案实体类
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "customer_id", length = 32)
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	@Transient
	public String getHealthArchiveId() {
		return healthArchiveId;
	}

	public void setHealthArchiveId(String healthArchiveId) {
		this.healthArchiveId = healthArchiveId;
	}

	@Column(name = "description", length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "attendant_id", length = 32)
	public String getAttendantId() {
		return attendantId;
	}

	public void setAttendantId(String attendantId) {
		this.attendantId = attendantId;
	}
	
	@Transient
	public String getAttendantName() {
		return attendantName;
	}

	public void setAttendantName(String attendantName) {
		this.attendantName = attendantName;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "health_archive_id")
	public MedicalCallHealthSymptom getHealthSymptom() {
		return healthSymptom;
	}

	public void setHealthSymptom(MedicalCallHealthSymptom healthSymptom) {
		this.healthSymptom = healthSymptom;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("customerId", customerId);
		obj.put("healthArchiveId", healthSymptom.getId());
		obj.put("healthSymptomName", healthSymptom.getName());
		obj.put("description", description);
		obj.put("attendantName", attendantName);
		obj.put("createTime", DateFormatUtils.format(createTime,"yyyy-MM-dd HH:mm:ss"));
		return obj.toString();
	}

}
